Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to python 3.7 #52

Closed
wants to merge 13 commits into from
Closed

Conversation

sweeneytr
Copy link

Versions prior to 3.7 are EoL, and the lack of access to from __future__ import annotations in <=3.6 make it not worth working around.

Pypi stats shows there is still some 3.6 utilization, but as breaking 2.7 support is typically handled by a major version bump, and going from 3.6 -> 3.7 is trivial, the regular maintaince of "a major bump happened" should be enough for them to push to 3.7.

Versions prior to 3.7 are EoL, and the lack of access to
`from __future__ import annotations` in <=3.6 make it not worth working
around.

Pypi stats shows there is still some 3.6 utilization, but as breaking 2.7 support is typically
handled by a major version bump, and going from 3.6 -> 3.7 is trivial, the regular
maintaince of "a major bump happened" should be enough for them to push
to 3.7.
@sweeneytr
Copy link
Author

This would resolve #48

@coveralls
Copy link

coveralls commented Nov 30, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 6b50420 on sweeneytr:master into a95c26f on stefankoegl:master.

@@ -1,15 +1,16 @@
language: python
dist: jammy
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults to 16.04 (whatever dist that is) which doesn't have beyond 3.9

- nightly
- pypy3
install:
- travis_retry pip install --upgrade pip setuptools wheel
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to work around default setuptools being broken in 3.9 image

__website__ = 'https://github.com/stefankoegl/python-json-pointer'
__license__ = 'Modified BSD License'
__author__ = "Stefan Kögl <stefan@skoegl.net>"
__version__ = "3.0"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major version bump

except ImportError: # Python 3
from collections import Mapping, Sequence
T = TypeVar("T")
TJsonPointer = TypeVar("TJsonPointer", bound="JsonPointer")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in places like @classmethod, where def foo(cls: Type[TJsonPointer]) -> TJsonPointer is dependent on the subclass. It's a small detail, but typing it correctly is really nice to people downstream.

In 3.11, PEP 673 makes this even easier, but since this was supporting every python version not EOL I didn't leverage it https://peps.python.org/pep-0673/


class _Singleton(type):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be overkill, but it made typing the Nothing object hints way easier to have a class it's an instance of. It could have been an empty class _Nothing: pass, but with ~5 lines more of code it gets the really nice property that every instance of _Nothing is the same instance.

Without that, checking default is _nothing would fail, as is checks id(lhs) == id(rhs) (aka "are they the same instance"? You can work around that by instead checking isinstance(x, _Nothing), but I prefer the syntax you had of is _nothing

pointer = JsonPointer(pointer)
return pointer.set(doc, value, inplace)
_pointer = JsonPointer(pointer)
return _pointer.set(doc, value, inplace)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some type engines (e.g. pylance) get confused when you reuse names in place like this

@sweeneytr
Copy link
Author

was fun fighting Travis. Anyhow, sorry for the mangled work, I applied black as an auto-formatter and it made the diff larger than I'd like, but I can't really put the genie back in it's bottle there. Will just leave it as is until complaints.

@stefankoegl
Copy link
Owner

Thanks for the great work! If we drop <= 3.7 here, this will break stefankoegl/python-json-patch. Would you be up for looking into that as well?

@sweeneytr
Copy link
Author

sweeneytr commented Dec 12, 2022 via email

@stefankoegl stefankoegl closed this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants